package com.example.dbsample.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * TODO 尚未验证这些是否可以先：FieldFill.INSERT
 */

/**
 * Entity基类
 *
 * @author 阿沐 babamu@126.com
 * <a href="https://maku.net">MAKU</a>
 */
@Data
@ToString
//public abstract class BaseEntity implements Serializable {
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    public static final String COLUMN_ID = "id";
    public static final String COLUMN_CREATED_BY = "created_by";
    public static final String COLUMN_UPDATED_BY = "updated_by";
    public static final String COLUMN_CREATED_DATE = "created_date";
    public static final String COLUMN_UPDATED_DATE = "updated_date";
    public static final String COLUMN_IS_DELETED = "is_deleted";

    public static final String[] COPY_IGNOrE_PROPERTIES = {COLUMN_ID, COLUMN_CREATED_BY, COLUMN_UPDATED_BY, COLUMN_CREATED_DATE,COLUMN_UPDATED_DATE,COLUMN_IS_DELETED};

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 创建者
     */
    @TableField(value = "creator", fill = FieldFill.INSERT)
    private Long  creator;

    @TableField(value = "created_by", fill = FieldFill.INSERT)
    private String createdBy;

    /**
     * 创建时间
     */
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    //private Date createTime;
    private LocalDateTime createdTime;

    /**
     * 更新者
     */
    @TableField(value = "updater", fill = FieldFill.INSERT_UPDATE)
    private Long updater;

    @TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
    private String updatedBy;

    /**
     * 更新时间
     */
    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
    //private Date updateTime;
    private LocalDateTime updatedTime;

    /**
     * 版本号
     */
    @Version
    @TableField(fill = FieldFill.INSERT)
    private Integer version;

    /**
     * 删除标记，1-是，0-否，默认0
     */
    @TableLogic(value = "0", delval = "1")
    @TableField(value = "deleted", fill = FieldFill.INSERT)
    private Integer deleted;

    /**
     * 业务线
     */
    @TableField(value = "biz_code")
    private String bizCode;
}
